home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / ccs_util.jar / com / commerceone / util / collection / EnumerationPair.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-12-09  |  1.1 KB  |  38 lines

  1. package com.commerceone.util.collection;
  2.  
  3. import com.commerceone.util.contract.Contract;
  4. import java.util.Enumeration;
  5.  
  6. public class EnumerationPair implements Enumeration {
  7.    private Enumeration begin;
  8.    private final Enumeration end;
  9.  
  10.    public Object nextElement() {
  11.       if (this.begin != null) {
  12.          Object returnVal = this.begin.nextElement();
  13.          if (!this.begin.hasMoreElements()) {
  14.             this.begin = null;
  15.          }
  16.  
  17.          return returnVal;
  18.       } else {
  19.          return this.end.nextElement();
  20.       }
  21.    }
  22.  
  23.    public EnumerationPair(Enumeration car, Enumeration cdr) {
  24.       Contract.require(car != null && cdr != null);
  25.       if (car.hasMoreElements()) {
  26.          this.begin = car;
  27.       } else {
  28.          this.begin = null;
  29.       }
  30.  
  31.       this.end = cdr;
  32.    }
  33.  
  34.    public boolean hasMoreElements() {
  35.       return this.begin != null ? this.begin.hasMoreElements() : this.end.hasMoreElements();
  36.    }
  37. }
  38.